<?php 

class Raid {
	/*
	功能
		显示活动报告
		计算DKP
	过程
		1.从数据库读入全部要用到数据,以数组形式保存
		2.计算DKP,并写入到数据库
		3.显示活动报告
	*/

	public $raidid;
	public $arrPlayers, $arrEvents; //数据数组
	public $arrRaidInfos;
	public $error_info;
	public $intFirstDown, $intBossDown;


	private $WillDelEvents;
			


	//解析核心
	public function RaidLoad($id) {
		if ($id!='' && is_numeric($id)) {
			$this->raidid = $id;
		}else{
			$this->error_info .= "\n类型错误raidid=$raidid";
			return false;
		}
		$this->arrRaidInfos = $this->getRaidInfo();
		$this->arrPlayers = $this->getPlayers();
		$this->arrEvents = $this->getEvents();

		$this->formatEventsMember();

		$this->DKPCalculation();
		
	}




	//初始化数组
	private function getRaidInfo() {
		$sql="select * from raid where id=".$this->raidid; //读取RAID基本信息
		if ($result = mysql_query($sql)) {
			$row = mysql_fetch_array($result);
			$arr['id'] = $row['id'];
			$arr['name'] = $row['raid_name'];
			$arr['start_time'] = $row['raid_actiontime'];
			$arr['end_time'] = $row['raid_endtime'];
			$arr['elapsed_sec'] = datediff($row['raid_actiontime'],$row['raid_endtime']);
			$arr['concentrate_time'] = $row['raid_concentratetime'];
			$arr['players'] = $row['raid_player'];
			$arr['player_count'] = null; //等成员初始化后再更新
			$arr['ruler'] = null; //弃用规则
			$arr['class'] = $row['raid_class'];
			$arr['step'] = $row['raid_step'];
			$arr['standard_player_counts'] = $row['raid_personnel'];
			$arr['plan'] = $row['raid_plan'];
			return $arr;
		}else{
			$error_info .= "\n活动未找到 $sql";
			return false;
		}
	}



	//初始化活动成员数组$arrPlayers
	private function getPlayers() {
		if ($arrlist = explode(',',trim($this->arrRaidInfos['players'],','))) {
			if ($arrlist[0] == '') {array_shift($arrlist);}
		}else{
			$error_info .= "\n活动成员数为零";
			return false;
		}

		foreach ($arrlist as $unit) {
			if ($unit == '') continue;
			$sql = "select * from player WHERE player_name='$unit'";
			if ($result = mysql_query($sql)) {
				$row = mysql_fetch_array($result);
				$array[$row['player_name']] = array();
				$array[$row['player_name']]['id'] = $row['id'];
				$array[$row['player_name']]['name'] = $row['player_name'];
				$array[$row['player_name']]['guildlevel']=$row['player_guildlevel']; //公会职务
				$array[$row['player_name']]['class']=$row['player_class']; //角色职业
				$array[$row['player_name']]['race']=$row['player_race']; //种族
				$array[$row['player_name']]['duty']=""; //担任职务,分数
				$array[$row['player_name']]['dkp']=0; //本次获得分数
				$array[$row['player_name']]['check']=""; //校验码
				$array[$row['player_name']]['events']=""; //加入离开事件集合
				$array[$row['player_name']]['cost']=0; //花费
			}else{
				$error_info .= "\n成员 $unit 未找到 $sql";
			}
		}
		return $array;
	}

	//初始化事件数组$arrEvents
	private function getEvents() {
		$arr = array();
		$sql="select * from raid_event where event_raidid=".$this->raidid." order by event_time , id desc";
		if ($result = mysql_query($sql)) {
			while ($row = mysql_fetch_array($result)) {
				array_push($arr,array(
					'class' => $row['event_class'], //类型
					'object' => $row['event_object'], //对象玩家
					'object2' => $row['event_object2'], //事物对象
					'dkp' => $row['event_dkp'], //涉及DKP
					'time' => $row['event_time'], //时间
					'player_count' => 0, //涉及成员人数
					'players' => "|", //涉及成员编号表
					'dkp2' => $row['event_dkp2'], //涉及DKP2
					'tooltip' => $row['event_object2_tooltip'], //物品tooltip
				));
				switch ($row["event_class"]) {
				case "首次":
					$Numfirstdown++;
					break;
				case "击杀":
					$Numfarmdown++;
					break;
				}
			}
			return $arr;
		}else{
			$error_info .= "\n未找到活动事件 $sql";
			return false;
		}
	}








	//合算每个成员的DKP分值
	public function DKPCalculation() {
		$EventDelList=",";
		//检查事件的合法性
		$sql="select * from raid_event where event_raidid=".$this->raidid." and (event_class='加入' or event_class='离开') order by event_time ,id desc";
		if ($result = mysql_query($sql)) {
			while ($row = mysql_fetch_array($result)) {
				foreach ($this->arrPlayers as $player) {
					if (($player['id'])==($row["event_object"])) {
						switch ($row["event_class"]) {
						case "加入":
							$player['check']=$player['check']."1";
							break;
						case "离开":
							$player['check']=$player['check']."0";
							break;
						} 
					} 
							
					// if instr(right(ArrPlayers(j,7),2),"00")>0 or instr(right(ArrPlayers(j,7),2),"11")>0 then 

					if ((strpos(substr($player[7],strlen($player[7])-(2)),"00") ? strpos(substr($player[7],strlen($player[7])-(2)),"00")+1 : 0)>0 || (strpos(substr($player[7],strlen($player[7])-(2)),"11") ? strpos(substr($player[7],strlen($player[7])-(2)),"11")+1 : 0)>0) {
						$this->error_info .= "\n事件合法性错误,成员 ".$player[1]." 的离开或加入事件不合理. "; //不合法
						if ((strpos($EventDelList,",".$row["id"].",") ? strpos($EventDelList,",".$row["id"].",")+1 : 0)<1) {
							$EventDelList=$EventDelList.$row["id"].",";
						} 
					//ArrPlayers(j,7)=left(ArrPlayers(j,7),len(ArrPlayers(j,7))-1)
					} 
				}
			}
		}
		if ($EventError!="") {
			print "<textarea name='' rows='6' style='width:100%;'>".$EventError."</textarea><input type='hidden' name='idlist' value='".$EventDelList."' />";
		} 



		//遍历成员遍历每个事件累积DKP到成员
		foreach ($this->arrPlayers as &$player) {
			echo "<br>/".$player['name'];
			foreach ($this->arrEvents as &$event) {
				if ($event['dkp']) {echo ' '.$event['dkp'];}
				//活动事件(固定分数)
				if ($event['class']=="活动事件") {
					$player['dkp']=$player['dkp']+$event['dkp'];
				} 
				//拾取,仓库,首次,发现,击杀,自定义
				if ($event['class']!="加入" || $event['class']!="离开") {
					switch ($event['class']) {
					case "拾取":
						if ($event['dkp2'] != '') {
							$player['dkp']=$player['dkp']+$event['dkp2'];
						}else{
							$player['dkp']=$player['dkp']+$event['dkp']/$event['player_count'];
						} 
						if (($player['id'])==($event['object'])) {
							$player['dkp']=$player['dkp']-$event['dkp'];
							$player['cost']=$player['cost']-$event['dkp'];
							$issue=$issue+$event['dkp'];
						}
						break;
					case "个人事件":
						if (($player['id'])==($event['id'])) {
							$player['dkp']=$player['dkp']+$event['dkp'];
						} 
						break;
					case "职务任命":
						if (($player['id'])==($event['id'])) {
							$player['dkp']=$player['dkp']+$event['dkp'];
							$player['duty']=$player['duty'].$event['object2'].",".$event['dkp']."|";
						} 
						break;
					case "仓库":
						echo "C";
						if ($event['dkp']!=0) {
							//$player['dkp']=$player['dkp']+$event['dkp'];
						} 
						//						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleBOE
						//						TotalDKP=TotalDKP+ RuleBOE
						break;
					case "分解":
						if ($event['dkp']!=0) {
							$player['dkp']=$player['dkp']+$event['dkp'];
						}else{
							$player['dkp']=$player['dkp']+$RuleENC;
							$event['dkp']=$RuleENC;
						} 
						//ArrPlayers(i,6) = ArrPlayers(i,6) + RuleENC
						//TotalDKP=TotalDKP+ RuleENC
						break;
					case "首次":
						if ($event['dkp']!=0) {
							$player['dkp']=$player['dkp']+$event['dkp'];
						}else{
							$player['dkp']=$player['dkp']+$RuleFirst;
							$event['dkp']=$RuleFirst;
						} 
						break;
					case "击杀":
						if ($event['dkp']!=0) {
							$player['dkp']=$player['dkp']+$event['dkp'];
						}else{
							$player['dkp']=$player['dkp']+$RuleFarm;
							$event['dkp']=$RuleFarm;
						} 
						break;
					case "团队事件":
						$player['dkp']=$player['dkp']+$event['dkp'];
						break;
					} //switch end.
				}
			}
			echo " /".$player['dkp'];
			if (strlen($player[8])>1) {
				$player['dkp']=$player['dkp']+$RuleAtt/2;
			}else{
				$player['dkp']=$player['dkp']+$RuleAtt;
			} 
			//	TotalDKP=TotalDKP+Cint(ArrPlayers(i,6))
			//	Response.write ArrPlayers(i,1)&" : "&Int(ArrPlayers(i,6))&"<br>"
		}
		return true;
	}









	//获取每个事件的参与人数
	private function formatEventsMember() {
		$i = 0;
		foreach ($this->arrEvents as &$event) {
			foreach ($this->arrPlayers as $player) {
				if ($this->chkintime($event['time'],$player['id'],$i)) {
					$event['player_count']++;
					$event['players'] .= $player['name']."|";
				}
			}
			$i++;
		}
	}


	//整理离开加入事件 ??
	private function formatEvents() {
		foreach ($this->arrPlayers as &$player) {
			$TempEvent="";
			foreach ($this->arrEvents as $event) {
				if (($event[0]=="加入" || $event[0]=="离开") && ($event['object'])==($player[0])) {
					if ($TempEvent=="" && $event[0]=="加入") {
						$TempEvent="J";
					}elseif ($TempEvent=="" && $event[0]=="离开") {
						$TempEvent="L";
					}
					$TempEvent=$TempEvent.",".$event['time'];
				} 
			}
			$player[8]=$TempEvent;
		}
	}





	private function sqlRaidUpdate () {
		return;
	}




	//更新DKP缓存表
	private function sqlDataUpdate() {
		// !($RaidStep=="3")
		$sql="select * from dkplist where raidid=".$_GET['id'];
		$result = mysql_query($sql);
		if ($result->recordcount==$RaidMaxPlayer+1) {
			$result->close;
			for ($i=0; $i<=$RaidMaxPlayer; $i=$i+1) {
				if ($ArrPlayers[$i][0]!="") {
					$conn->execute("update dkplist set dkp=".$ArrPlayers[$i][6]." where playerid=".$ArrPlayers[$i][0]." and raidid=".$_GET['id']);
				}
			}
		}else{
			//删除
			$sql="Delete * from dkplist where raidid=".$_GET['id'];
			mysql_query($sql);
			//再添加
			$sql="select * from dkplist where raidid=".$_GET['id'];
			$result = mysql_query($sql);
			for ($i=0; $i<=$RaidMaxPlayer; $i=$i+1) {
				$result->addnew;
				$result["playerid"]=$ArrPlayers[$i][0];
				$result["raidid"]=$_GET['id'];
				$result["dkp"]=$ArrPlayers[$i][6];
				$result->update;
			}
		}
		return $function_ret;
	} 



	//删除指定ID的事件,可以是由,号分隔的多个ID
	private function sqlDelEvents($strList) {
		$strList=explode(",",$strList);
		foreach ($strList as $row) {
			$sql = "Delete From Raid_event where id=".$row;
			if (!mysql_query($sql)) { $error_info .= "\n删除错误 $sql".mysql_error();};
		}
		return true;
	}




	//检查t事件发生时pid成员是否在团队,N是该事件的索引
	private function chkintime($t,$pid,$N) {
		$Tn=$N;

		//向前查找,
		if ($N>0) {
			for ($k=$N; $k>=0; $k=$k-1) {
				if ($this->arrEvents[$Tn]['class']=="离开" && ($this->arrEvents[$Tn]['object'])==($pid)) {
					return false;
				}elseif ($this->arrEvents[$k]['class']=="加入" && ($this->arrEvents[$k]['object'])==($pid)) {
					return true;
				} 
				$Tn=$Tn-1;
			}
		} 

		//向后查找
		if ($N<count($ArrEvents)) {
			for ($k=$N+1; $k<=count($ArrEvents); $k=$k+1) {
				if ($this->arrEvents[$k]['class']=="加入" && ($this->arrEvents[$k]['object'])==($pid)) {
					return false;
				}elseif ($this->arrEvents[$k]['class']=="离开" && ($this->arrEvents[$k]['object'])==($pid)) {
					return true;
				} 
			}
		} 
		return false;
	} 




	//显示一个调试信息框
	public function debugg() {
		echo "<textarea style='width:600px;height:400px;'>";
		print_r($this->arrRaidInfos);
		echo "\n\n";
		print_r($this->arrPlayers);
		echo "\n\n";
		print_r($this->arrEvents);
		echo "\n\n";
		echo "\n";
		echo "\n";
		echo "\n";
		echo "\n";
		echo "\n";
		print ($this->error_info);
		echo "</textarea>";
	}






	//返回两个时间相距对于总时间的百分比
	private function PerTime($st,$et) {
		$EventTimeUsed=datediff($st,$et);
		$per =intval(($EventTimeUsed/$this->arrRaidInfos['elapsed_sec'])*100);
		if ($per>=100) {
			$per = 99;
		}
		if ($per>98) {
			$per = 98;
		}
		return $per;
	} 

	//PerTime加强版,直接生成长度IMG,另加一个小数部分估算补值
	private function PerTimeIMG($st,$et) {
		//<div class='tline_killed'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"''>
		$EventTimeUsed=datediff($st,$et);
		$per=intval(($EventTimeUsed/$this->arrRaidInfos['elapsed_sec'])*100);
		if ($per>=100) {
			$per = 99;
		}
		if ($per>98) {
			$per = 98;
		}
		$PerTimeDec=($EventTimeUsed/$this->arrRaidInfos['elapsed_sec']*100-$Per)*10; //精度补值
		return "<img src='style/images/gb.gif' height='1px' width='".$per."%'>"."<img src='style/images/gb.gif' height='1px' width='".$PerTimeDec."px'>";
	}














	//事件线
	public function viewEvents() {
		global $StylePath;
		$starttime = $this->arrRaidInfos['start_time'];
		$html .= "<div class='c'>";
		foreach ($this->arrEvents as $event) {
			switch ($event['class']) {
		case "拾取":
			if ($event['dkp2']!="") {
				$html .= "<div class='tline_looted".mt_rand(1,5)."'>".$this->PerTimeIMG($starttime,$event['time'])."<img src='".$StylePath."/images/event1.gif' class='eventico' alt='<h4>拾取: ".$event['object2']."</h4><p>".$event['time']."<br>".id2name2($event['object'])." ".$event['dkp']."分获得<br>团队共".$event['player_count']."人. 每人<b>".$event['dkp2']."</b>分</p>'></div>";
			}else{
				$html .= "<div class='tline_looted".mt_rand(1,5)."'>".$this->PerTimeIMG($starttime,$event['time'])."<img src='".$StylePath."/images/event1.gif' class='eventico' alt='<h4>拾取: ".$event['object2']."</h4><p>".$event['time']."<br>".id2name2($event['object'])." ".$event['dkp']."分获得<br>团队共".$event['player_count']."人. 每人<b>".number_format($event['dkp']/$event['player_count'],2)."</b>分</p>'></div>";
			} 
			break;
		case "仓库":
			$html .= "<div class='tline_nulllooted".mt_rand(1,3)."'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event2.gif' class='eventico' alt='<h4>仓库: ".$event['object2']."</h4><p>".$event['time']."<br>".id2name2($event['object'])."<br>每人<b>".$event['dkp']."</b>分</p>'></div>";
			break;
		case "分解":
			$html .= "<div class='tline_nulllooted".mt_rand(1,3)."'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event2.gif' class='eventico' alt='<h4>分解: ".$event['object2']."</h4><p>".$event['time']."<br>".id2name2($event['object'])."<br>每人<b>".$event['dkp']."</b>分</p>'></div>";
			break;
		case "首次":
			$html .= "<div class='tline_killed'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event4.gif' class='eventico' alt='<h4>".$event['object2']."</h4><p>".$event['time']."<br>首次击杀!!</p>'></div>";
			break;
		case "击杀":
			$html .= "<div class='tline_killed'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event5.gif' class='eventico' alt='<h4>".$event['object2']."</h4><p>".$event['time']."<br>击杀成功,每人".$event['dkp']."分</p>'></div>";
			break;
		case "团队事件":
			$html .= "<div class='tline_team'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event6.gif' class='eventico' alt='<h4>团队事件</h4><p>".$event['time']."<br>".$event['object2']."<br>每人".$event['dkp']."分</p>'></div>";
			break;
		case "个人事件":
			$html .= "<div class='tline_personal'><img src='".$StylePath."/images/gb.gif' height='1px' width='".$this->PerTime($starttime,$event['time'])."%'><img src='".$StylePath."/images/event7.gif' class='eventico' alt='<h4>个人事件</h4><p>".$event['time']."<br>".id2name2($event['object'])."<br>".$event['object2']." ".$event['dkp']."分</p>'></div>";
			break;
		case "活动事件":
			$HtmlEventGlobal=$event['object2'].":".$event['dkp']."分 ";
			break;
			} 
		}
		$html = "<div class='timeline outframe'><h3>物品和事件 [".$HtmlEventGlobal."]</h3>".$html;
		$html .= "</div></div>";
		return $html;
	}

	//物品列表
	public function viewItems() {
		$html .= "<table class='lootlist outframe'>";
		$html .= "<tr><th><div class='title'><img src='images/icon/box.jpg' width='64' height='64'>物品掉落</div><div class='filter'></div></th></tr><tr><td>";
		foreach ($this->arrEvents as $event) {
			switch ($event['class']) {
			case "拾取":
				if ($event['dkp2']!="") {
					$html .= "<div class='item'><div class='dkp'>".$event['dkp']."/".$event['dkp2']."</div>".eqpic($event['object2'],$event[8])."<div class='itemname'>".delItemID($event['object2'])."</div><div class='target'>".id2name2($event['object'])."</div><div class='time'>".time_type($event['time'],4)."</div></div>"."\r\n";
					$PraDKP=$PraDKP+$event['dkp'];
				}else{
					$html .= "<div class='item'><div class='dkp'>".$event['dkp']."</div>".eqpic($event['object2'],$event[8])."<div class='itemname'>".delItemID($event['object2'])."</div><div class='target'>".id2name2($event['object'])."</div><div class='time'>".time_type($event['time'],4)."</div></div>"."\r\n";
					$PraDKP=$PraDKP+$event['dkp'];
				}
				break;
			case "仓库":
				$html .= "<div class='item'><div class='dkp'>".$RuleBOE."/a</div>".eqpic($event['object2'],$event[8])."<div class='itemname'>".delItemID($event['object2'])."</div><div class='target'>仓库</div><div class='time'>".time_type($event['time'],4)."</div></div>"."\r\n";
				$PraDKP=$PraDKP+$RuleBOE*$event['player_count'];
				break;
			case "分解":
				$html .= "<div class='item'><div class='dkp'>".$RuleENC."/a</div>".eqpic($event['object2'],$event[8])."<div class='itemname'>".delItemID($event['object2'])."</div><div class='target'>分解</div><div class='time'>".time_type($event['time'],4)."</div></div>"."\r\n";
				$PraDKP=$PraDKP+$RuleENC*$event['player_count'];
				break;
			} 
		}
		$html .= "</td></tr></table>";
		return $html;
	}

	//概要
	public function viewRaidInfo() {
		$html .= "<table class='outframe interlace'>";
		$html .= "<tr><th colspan='6'><div class='title'><img src='images/icon/banner.jpg' width='64' height='64'>活动:".$this->arrRaidInfos['name']."</div><div class='filter'>";
		if (CheckAdmin() && $this->arrRaidInfos['step']<3) {
			$html .= "<a href='admin_raid.php?action=edit&amp;id=".$this->raidid."' class='abtn3'>修改基本信息</a> <a href='admin_report.php?action=collect&id=".$this->raidid."' class='abtn3'>编辑活动人员</a> <a href='admin_report.php?action=collect2&id=".$this->raidid."' class='abtn3'>编辑活动事件</a>";
		} 
		$html .= " <form method='post' action='raid_report.php' name='form22'>".selectraid()."</form> </div></th></tr>"."\r\n";
		$html .= "<tr><td>开始:".$this->arrRaidInfos['start_time']."</td><td>结束:".$this->arrRaidInfos['end_time']."</td><td>历时:".$this->arrRaidInfos['elapsed_sec']."</td><td>参加人数:".($RaidMaxPlayer+1)."/".$this->arrRaidInfos['standard_player_counts']." 人</td><td>DKP制度:[X]</td><td><b>".LogicM($RaidStep,"0|1|3","草稿|报告未归档|报告已归档","|")."</b></td></tr>";
		$html .= "<tr><td>首杀".$intFirstDown."</td><td>-</td><td>击杀".$intBossDown."</td><td>-</td><td>DKP分类:".getRaidClassText($raidclass)."</td><td>-</td></tr>";
		$html .= "<tr><td colspan='6'>".$this->arrRaidInfos['plan']."</td></tr>";
		$html .= "</table>";
		return $html;
	}

	//成员时间线
	public function viewMembers() {
		global $StylePath;
		$html .= "<table class='raidline outframe'>";
		$html .= "<tr><th><div class='title'><img src='images/icon/human_f.gif' width='64' height='64'>人员出勤</div></th></tr>";
		foreach ($this->arrPlayers as $player) {
			$AllRto=0;
			$html .= "<tr><td>";
			$html .= "<div class='single'>";
			$html .= "<span><img src='".getProfessionSmallIco($player['class'])."' />".id2name($player['id']).office2img($player['duty'])."</span>";
			if ($player[8]=="") {
				$html .= "<img src='".$StylePath."/images/gall.gif' height='20px' width='100%' alt='全程'/>";
			}else{
				$ArrJL=explode(",",$player[8]);
				for ($j=1; $j<=count($ArrJL); $j=$j+1) {
					if ($j+1>count($ArrJL)) {
						$JL2=$RaidEndTime;
						$Rto=PerTime($ArrJL[$j],$JL2);
					}else{
						$JL2=$ArrJL[$j+1];
						$Rto=PerTime($ArrJL[$j],$JL2);
					} 
					$AllRto=$AllRto+$Rto;
					if ($j==1) {
						$html .= "<img src='".$StylePath."/images/".GAorGB($ArrJL[0],0)."' height='20px' width='".PerTime($RaidActionTime,$ArrJL[$j])."%' alt='".PerTime($RaidActionTime,$ArrJL[$j])."% ".$TimeValue[$RaidActionTime]." - ".$TimeValue[$ArrJL[$j]]."'/>";
					} 
					$html .= "<img src='".$StylePath."/images/".GAorGB($ArrJL[0],$j)."' height='20px' width='".$Rto."%' alt='".$Rto."% ".$TimeValue[$ArrJL[$j]]." - ".$TimeValue[$JL2]."'/>";
				}
			} 
			$html .= "<h6>";
			$html .= number_format($player['dkp'],2);
			if (intval($player['cost'])!=0) {
				$html .= " (花费:".abs(intval($player['cost'])).")";
			} 
			$html .= "</h6>";
			$issue=$issue+$player[6];
			$html .= "</div>";
			$html .= "</td></tr>";
		}
		$html .= "</table>";
		return $html;
	} 
	

	//操作按钮
	public function viewddContorl() {
		return false;
	}


	//留言本
	public function viewGuestBook() {
		//if ($lvlGBook==0 || $lvlGBook!=3) { return false; } 
		$html .= "<div class='info outframe'>";
		$html .= "<h3>公会动态</h3>";
		$sql="select * from gbook where gbook_raidid='".$_GET['id']."' order by id";
		if ($result = mysql_query($sql)) {
			while ($row = mysql_fetch_array($result)) {
				$html .= "<div>";
				$html .= "<h4>".$Htmlencode2[$row["gbook_poster"]]."</h4>";
				if (CheckAdmin()) {
					$html .= "<p>".$Htmlencode2[($row["gbook_content"])]." <span>[<a href='admin_guest.php?del=".$row["id"]."'>删除</a>]</span></p>";
				}else{
					$html .= "<p>".$Htmlencode2[($row["gbook_content"])]."</p>";
				} 
				$html .= "</div>";
			}
		}else{
			$html .= "没有留言";
		}
		
		$html .= "<form name='put_log' method='post' action='gbook.php?action=raidadd'>Name: <input type='text' name='gb_author' size='20' value='' /><br>"
		."<textarea name='gb_text' rows='5' cols='60' id='l_content'></textarea>"
		."<input type='hidden' name='gbook_id' value='".$_GET['id']."' /><input type='submit' value='留 言' /></form></div>";
		return $html;
	}

}








?>
